<!--
 * @Description:验证文件夹路径
 * @Author: Sun
 * @Date: 2019-07-01 20:05:50
 * @LastEditors: Sun
 * @LastEditTime: 2019-07-15 22:23:40
 -->
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>验证文件夹路径</title>
	
	<script>
		window.onload = function () {
			let dv = document.getElementById("file")
          dv.onchange=function(){
						var path=this.value
						console.log("path",path)
						var su=path.substr(path.lastIndexOf("."))
						var sux=path.substr(path.lastIndexOf(".")).toUpperCase()
						console.log("pp",su)
						if(sux==".JPG"){
						this.nextSibling.innerHTML="格式正确"
						console.log("pyyyp",sux==".JPG")
						}
					}
		}
	</script>
</head>

<body>
	截取字符串操作 <br>
	1 substr(3，6）参数 2 截取多少位数 6个数字<br>
	2 slice(3,6) 从第3个开始一直到最后 6是索引号的位子<br>
		 从0开始 不包含6<br>
	2.1 slice(-1) 负数就冲右便开始取<br>
	3 substring(6,3) 始终会把小值放在起事位置 <br>
		substring(3,6)<br>
  5 a.concat(b) //链接字符串<br>
  <input type="file" name="" id="file"><span></span>
</body>

</html>